package net.sxnic.ugr.utils;

import java.util.Random;

public class UcenterUtils {
	
	/**
	 * 获取每位都不重复的随机数
	 * @param digit 随机数的位数
	 * @return 指定位数的随机数
	 */
	public static String getRadomNum(int digit)
	{
		StringBuffer sb =new StringBuffer();
		int[] array = {0,1,2,3,4,5,6,7,8,9};
		Random rand = new Random();
		for (int i = 10; i > 1; i--) {
			int index = rand.nextInt(i);
			int tmp = array[index];
			array[index] = array[i-1];
			array[i-1] = tmp;
		}
		
		for(int i = 0; i < digit; i++)
		{
			sb.append(array[i]);
		}
		
		return sb.toString();
	}
	
}
